<template>
  <div class="container">
    <van-nav-bar
      title="预付卡充值"
      left-text=""
      left-arrow
      @click-left="routeToPath('')"
    />
    <div class="consume-nav">
      <ul>
        <li v-for="(i, index) in ItemClassList" @click="clicknav(index)" :class="active == index?'active':''">
          <div class="icon">
            <van-icon name="envelop-o" />
          </div>
          <div class="name">{{ i }}</div>
        </li>
      </ul>
    </div>
    <div class="consume-list">
      <div class="list-image" v-for="i in 4">
        <img class="max" src="http://dummyimage.com/400x240/00405d/FFF&text=hello" alt="">
      </div>
    </div>
  </div>
</template>

<script>
import { Icon } from 'vant';
import { NavBar } from 'vant';
import axios from 'axios';
export default {
  name: 'ConsumeIndex',
  data() {
    return {
      active: 0,
      nav: [{
        name: '新加坡',
        type: 0,
      },{
        name: '马来西亚',
        type: 0,
      },{
        name: '泰国',
        type: 0,
      },{
        name: '菲律宾',
        type: 0,
      },{
        name: '印度尼西亚',
        type: 0,
      },{
        name: '印度',
        type: 0,
      }],
      itemClassList: null,
    }
  },
  components: {
    [Icon.name]:Icon,
    [NavBar.name]:NavBar,
  },
  created() {
    this.getItemClassList()
  },
  methods: {
    clicknav(index){
      this.active = index
    },
    // 获取充值列表
    getItemClassList() {
      axios.get(this.URL.host+'/web/api/itemclass_list')
      .then((res)=> {
        this.ItemClassList = res.data.data;
        console.log(this.ItemClassList);
      })
      .catch((error) => {
        console.log(error);
      });
    }
  }
}
</script>
<style lang="scss" scoped>
  .consume-nav{

    ul{
      width: 2.4rem;
      float: left;
      padding-bottom: 2rem;
      background-color: #eee;
    }
    li{
      padding: .5rem 0;
      text-align: center;
      .icon{
        width: .6rem;
        display: inline-block;
        .van-icon{
          font-size: .8rem;
        }
      }
      .name{
        font-size: .34rem;
        color: #555;
      }
    }
    .active{
      background-color: #E6A23C;
      .icon .van-icon{
        color: #fff;
      }
      .name{
        color: #fff;
      }
    }
  }
  .consume-list{
    float: left;
    width: 7.6rem;
    overflow: hidden;
    padding-top: .4rem;
    .list-image{
      padding: 0 .4rem;
      margin-bottom: .4rem;
    }
  }
</style>
